// 定义食物类FOOD
class Food {
    element: HTMLElement | null;

    constructor() {
        this.element = document.getElementById('food');
    }

    // 获取食物x轴坐标
    get X() {
        return this.element?.offsetLeft;
    }

    // 获取食物y轴坐标
    get Y() {
        return this.element?.offsetTop;
    }

    // 修改食物位置
    changeXY(x: number = Math.round(Math.random() * 30) * 10, y: number = Math.round(Math.random() * 30) * 10) {
        this!.element!.style!.left = x + 'px';
        this!.element!.style!.top = y + 'px';
        return { x, y };
    }
}

export default Food;
